// DatabaseCombo.cpp : implementation file
//

#include "stdafx.h"
#include "AUSlotsTester.h"
#include "DatabaseCombo.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDatabaseCombo

CDatabaseCombo::CDatabaseCombo()
{
}

CDatabaseCombo::~CDatabaseCombo()
{
}


BEGIN_MESSAGE_MAP(CDatabaseCombo, CComboBox)
	//{{AFX_MSG_MAP(CDatabaseCombo)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDatabaseCombo message handlers

void CDatabaseCombo::Load(_SQLServer* pServer)
{
	CWaitCursor wait;

	ResetContent();

	CComPtr<Databases> pDatabases;
	
	if ( SUCCEEDED( pServer->GetDatabases( &pDatabases ) ) )
	{
		LONG nDatabases = 0;
		
		pDatabases->GetCount( &nDatabases );

		for ( LONG n = 0; n < nDatabases; n++ )
		{
			CComPtr<_Database> pDatabase;
			CComVariant var;
			CComVariant varOwner;

			var = n;
			
			if ( SUCCEEDED( pDatabases->Item( var, varOwner, &pDatabase ) ) )
			{
				CComBSTR bstrName;

				if ( SUCCEEDED( pDatabase->GetName( &bstrName ) ) )
				{
					CString str = bstrName;

					AddString( str );
				}
			}
		}
	}
}
